package com.ruoyi.yun.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yun.domain.YunProfileCaroffline;
import com.ruoyi.yun.service.IYunProfileCarofflineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆离线登记Controller
 * 
 * @author ruoyi
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/yun/caroffline")
public class YunProfileCarofflineController extends BaseController
{
    @Autowired
    private IYunProfileCarofflineService yunProfileCarofflineService;

    /**
     * 查询车辆离线登记列表
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:list')")
    @GetMapping("/list")
    public TableDataInfo list(YunProfileCaroffline yunProfileCaroffline)
    {
        startPage();
        List<YunProfileCaroffline> list = yunProfileCarofflineService.selectYunProfileCarofflineList(yunProfileCaroffline);
        return getDataTable(list);
    }

    /**
     * 导出车辆离线登记列表
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:export')")
    @Log(title = "车辆离线登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YunProfileCaroffline yunProfileCaroffline)
    {
        List<YunProfileCaroffline> list = yunProfileCarofflineService.selectYunProfileCarofflineList(yunProfileCaroffline);
        ExcelUtil<YunProfileCaroffline> util = new ExcelUtil<YunProfileCaroffline>(YunProfileCaroffline.class);
        util.exportExcel(response, list, "车辆离线登记数据");
    }

    /**
     * 获取车辆离线登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yunProfileCarofflineService.selectYunProfileCarofflineById(id));
    }

    /**
     * 新增车辆离线登记
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:add')")
    @Log(title = "车辆离线登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YunProfileCaroffline yunProfileCaroffline)
    {
        return toAjax(yunProfileCarofflineService.insertYunProfileCaroffline(yunProfileCaroffline));
    }

    /**
     * 修改车辆离线登记
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:edit')")
    @Log(title = "车辆离线登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YunProfileCaroffline yunProfileCaroffline)
    {
        return toAjax(yunProfileCarofflineService.updateYunProfileCaroffline(yunProfileCaroffline));
    }

    /**
     * 删除车辆离线登记
     */
    @PreAuthorize("@ss.hasPermi('yun:caroffline:remove')")
    @Log(title = "车辆离线登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yunProfileCarofflineService.deleteYunProfileCarofflineByIds(ids));
    }
}
